/**
 * 文 件 名:  ContentService.java
 * 版      权:  财之道  Copyright ©2011-2015 All Rights Reserved
 * 描      述:  
 */
package com.czd.support.service;

import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import com.czd.base.model.Paginate;
import com.czd.base.service.BaseService;
import com.czd.support.model.Content;

/**
 * @Description  内容业务类
 * 
 * @Author  Jun.Yang
 * @Date    2015年3月17日 下午2:57:24
 * @Version v1.0
 */
@Service
public class ContentService extends BaseService<Content> {
	public boolean insert(Content content) {
		return this.insert(sqlId("insert"), content);
	}
	
	public boolean update(Content content) {
		return this.update(sqlId("update"), content);
	}
	
	public boolean delete(int id) {
		return this.delete(sqlId("delete"), id);
	}
	
	public Content findById(int id) {
		return this.selectOneById(sqlId("findById"), id);
	}
	
	public Paginate queryForPage(Content content , String kw) {
		content.setWhere(" 1=1");
        if(StringUtils.isNotBlank(kw)){
        	content.setWhere(content.getWhere() + " and (title like '"+kw+"%' or originUrl like '"+kw+"%' or id like '"+kw+"%')");
        }
		return this.queryForPaginate(sqlId("queryForPage"), content);
	}
	
	public List<Content> queryByCode(int code){
		return this.selectList(sqlId("queryByCode"), code);
	}
	
}
